<?php

use think\Facade\Route;
use think\Facade\Env;

Route::domain(Env::get('app.api_url'), function () {
    header("Access-Control-Allow-Origin: *");
    header('Access-Control-Allow-Methods: POST, PUT, GET, OPTIONS, DELETE, HEAD, PATCH');
    header("Access-Control-Allow-Headers: token,tokens,language, Origin, X-Requested-With, Content-Type, Accept");
    Route::miss(function () {
        $result = [
            'code' => 1,
            'msg'  => '接口不存在',
            'time' => time(),
            'data' => [],
        ];
        return json($result);
        exit();
    });
    Route::group('User', function () {
        Route::post('getlogin', '/getlogin'); //手机号授权登陆
        Route::get('info', '/info'); //登录
        Route::rule('address', '/address'); //地址管理
        Route::rule('cart', '/cart'); //地址管理
        Route::post('cart_del', '/cart_del'); //地址管理
        Route::post('address_del', '/address_del'); //地址管理
        Route::post('putorder', '/putorder'); //订单提交
        Route::post('orderstatus', '/orderstatus'); //状态变更
        Route::get('orderlist', '/orderlist'); //订单列表
        Route::post('checkorder', '/checkorder'); //订单列表
        Route::get('orderdetail', '/orderdetail'); //订单列表
        Route::rule('message', '/message'); //反馈信息
        Route::post('edituser', '/edituser'); //订单列表
        Route::rule('gettaocan', '/gettaocan'); //订单列表
    })->prefix('User');


    Route::group('Other', function () {
        Route::get('getstreet', '/getstreet'); //获取定位信息
        Route::get('getconfig', '/getconfig'); //获取定位信息
        Route::get('addressjson', '/addressjson'); //获取地址库
        Route::get('agentinfo', '/agentinfo'); //获取地址库
        Route::rule('oss', '/oss'); //图片上传
        Route::get('street', '/street'); //获取街道列表
        Route::get('cate', '/cate'); //获取平台分类
        Route::get('subcate', '/subcate'); //获取平台分类
        Route::get('product', '/product'); //获取平台分类
        Route::get('banner', '/banner'); //获取平台分类
        Route::get('annous', '/annous'); //获取平台分类
    })->prefix('Other');
})->bind('api')->prefix('api');
